1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module soup.Requester;
26 
27 private import glib.ConstructionException;
28 private import glib.ErrorG;
29 private import glib.GException;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 private import soup.Request;
33 private import soup.SessionFeatureIF;
34 private import soup.SessionFeatureT;
35 private import soup.URI;
36 private import soup.c.functions;
37 public  import soup.c.types;
38 
39 
40 /** */
41 public class Requester : ObjectG, SessionFeatureIF
42 {
43 	/** the main Gtk struct */
44 	protected SoupRequester* soupRequester;
45 
46 	/** Get the main Gtk struct */
47 	public SoupRequester* getRequesterStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return soupRequester;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected override void* getStruct()
56 	{
57 		return cast(void*)soupRequester;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (SoupRequester* soupRequester, bool ownedRef = false)
64 	{
65 		this.soupRequester = soupRequester;
66 		super(cast(GObject*)soupRequester, ownedRef);
67 	}
68 
69 	// add the SessionFeature capabilities
70 	mixin SessionFeatureT!(SoupRequester);
71 
72 
73 	/** */
74 	public static GType getType()
75 	{
76 		return soup_requester_get_type();
77 	}
78 
79 	/** */
80 	public this()
81 	{
82 		auto __p = soup_requester_new();
83 
84 		if(__p is null)
85 		{
86 			throw new ConstructionException("null returned by new");
87 		}
88 
89 		this(cast(SoupRequester*) __p, true);
90 	}
91 
92 	/** */
93 	public Request request(string uriString)
94 	{
95 		GError* err = null;
96 
97 		auto __p = soup_requester_request(soupRequester, Str.toStringz(uriString), &err);
98 
99 		if (err !is null)
100 		{
101 			throw new GException( new ErrorG(err) );
102 		}
103 
104 		if(__p is null)
105 		{
106 			return null;
107 		}
108 
109 		return ObjectG.getDObject!(Request)(cast(SoupRequest*) __p, true);
110 	}
111 
112 	/** */
113 	public Request requestUri(URI uri)
114 	{
115 		GError* err = null;
116 
117 		auto __p = soup_requester_request_uri(soupRequester, (uri is null) ? null : uri.getURIStruct(), &err);
118 
119 		if (err !is null)
120 		{
121 			throw new GException( new ErrorG(err) );
122 		}
123 
124 		if(__p is null)
125 		{
126 			return null;
127 		}
128 
129 		return ObjectG.getDObject!(Request)(cast(SoupRequest*) __p, true);
130 	}
131 }